﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App1AppHandler;
using Reborn_WorldServer.App1AppHandler;

namespace Reborn_Server.App1AppHandler
{
    public class Spell_Bind : TargetSpell
    {
        public void Cast(CreatureBase myCreatureBase, int CastLevel, long CreatureGUID)
        {
            List<MapItem> MapItemsWithin12;
            if (base.InitializeCast(myCreatureBase, CastLevel, CreatureGUID, false, out MapItemsWithin12) == false)
                return;

            if (!(TargetCreatureBase is Character))
            {
                myCreatureBase.SendMessage("You may only bind other players!", "server");
                myCreatureBase.PlaySound("Ding", myCreatureBase.MapX, myCreatureBase.MapY);

                return;
            }

            if (TargetCreatureBase != myCreatureBase)
            {
                PendingBindRequest bindRequest = new PendingBindRequest((Character)TargetCreatureBase,
                    myCreatureBase.Name + " wishes to bind your spirit to your current location. Upon ressurection, your essence will return to this point. \n\nDo you accept?");
            }
            else
            {
                Character character = (Character)myCreatureBase;
                character.BindMapID = myCreatureBase.MapID;
                character.BindMapX = myCreatureBase.MapX;
                character.BindMapY = myCreatureBase.MapY;
                myCreatureBase.SendMessage("Your spirit is now bound to your current location.", "server");
            }
        }
    }
}
